package org.example.design.prototype;

import lombok.Data;

import java.io.Serializable;

/**
 * @author huangshen
 * @version 0
 * @description Sheep
 * @since 2022/1/29 21:42
 */
@Data
public class Sheep implements Serializable, Cloneable {
    private String name;
    private int age;
    private String color;
    private CloneSheep lover;

    public Sheep(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        Object sheep = super.clone();
        Sheep copySheep = (Sheep) sheep;
        copySheep.lover = (CloneSheep) DeepClone.deepClone(lover.clone());
        return copySheep;
    }
}
